package com.study.common;

import java.io.Serializable;

/**
 * 统一的回数据对象
 *
 * @author lemontree
 * @version 2.0, 2017/7/04
 * @since 2.0
 */
public class Result<T> implements Serializable {

    private static final long serialVersionUID = 1L;

    private T data;

    private String code;

    private String message;

    public Result() {
    }

    public Result(T data) {
        this.data = data;
    }

    public Result(String code, String message) {
        this.code = code;
        this.message = message;
    }

    public Result(T data, String code, String message) {
        this.data = data;
        this.code = code;
        this.message = message;
    }

    public static <T> Result of(T data) {
        return new Result(data);
    }

    public static <T> Result of(String code, T data) {
        Result result = new Result(data);
        result.setCode(code);

        return result;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

}
